package cn.edu.sgu.www.mhxysy.controller.repository;

import cn.edu.sgu.www.mhxysy.consts.CustomConstants;
import cn.edu.sgu.www.mhxysy.consts.CustomMessages;
import cn.edu.sgu.www.mhxysy.consts.MimeTypes;
import cn.edu.sgu.www.mhxysy.entity.repository.PackageGrid;
import cn.edu.sgu.www.mhxysy.restful.JsonResult;
import cn.edu.sgu.www.mhxysy.service.repository.PackageGridService;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotBlank;
import java.util.List;

/**
 * @author 沐雨橙风ιε
 * @version 1.0
 */
@Api(tags = "包裹格子管理")
@ApiSupport(author = CustomConstants.AUTHOR)
@Validated
@RestController
@RequestMapping(path = "/package_grid", produces = MimeTypes.APPLICATION_JSON_CHARSET_UTF_8)
public class PackageGridController {

    private final PackageGridService packageGridService;

    @Autowired
    public PackageGridController(PackageGridService packagePropService) {
        this.packageGridService = packagePropService;
    }

    @ApiOperation("查询角色的包裹格子列表")
    @RequestMapping(value = "/selectByRoleId", method = RequestMethod.GET)
    public JsonResult<List<PackageGrid>> selectByRoleId(
            @ApiParam(name = "roleId", value = "角色ID", required = true)
            @NotBlank(message = CustomMessages.ROLE_ID_NOT_NULL) String roleId) {
        List<PackageGrid> list = packageGridService.selectByRoleId(roleId);

        return JsonResult.success(null, list);
    }

}